﻿<!DOCTYPE HTML>
<html>
<head>
    <title>后台登录</title>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/public/hui/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="/public/hui/static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
<link href="/public/hui/static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="/public/hui/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
    <style>
        .error{
            margin-right: 50px;
        }
    </style>
</head>
<script type="text/javascript" src="/public/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="/public/hui/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="/public/lib/validate/jquery.validate.min.js"></script>
<script type="text/javascript" src="/public/lib/layer/layer.js"></script>
<body>
<input type="hidden" id="TenantId" name="TenantId" value="" />
<div class="header"></div>
<div class="loginWraper">
	<div id="loginform" class="loginBox">
		<form class="form form-horizontal" action="" method="post" id="form">
			<div class="row cl">
				<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
				<div class="formControls col-xs-8">
					<input id="" name="username" type="text" placeholder="账户" class="input-text size-L">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
				<div class="formControls col-xs-8">
					<input id="" name="password" type="password" placeholder="密码" class="input-text size-L">
				</div>
			</div>
			<div class="row cl">
				<div class="formControls col-xs-8 col-xs-offset-3">
					<input class="input-text size-L" type="text" name="code" placeholder="验证码" onblur="if(this.value==''){this.value='验证码:'}" onclick="if(this.value=='验证码:'){this.value='';}" value="验证码:" style="width:150px;">
					<?php echo $image;?>
					<a id="kanbuq" href="javascript:;" onclick="new_captcha()">看不清,换一张</a>
				</div>
			</div>
			<div class="row cl">
				<div class="formControls col-xs-8 col-xs-offset-3">
					<input name="" type="submit" class="btn btn-success radius size-L" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
				</div>
			</div>
		</form>
	</div>
</div>
<div class="footer">Copyright 你的公司名称 by H-ui.admin.page.v3.0</div>


<script>

    $( "#form" ).validate({
        rules: {
            username: {
                required: true,
                minlength:5
            },
            password: {
                required: true
            }
        },
        onkeyup: false,
        focusCleanup: true,
        success: "valid",
        submitHandler: function (form) {
            $.ajax({
                dataType: 'json',
                type: 'post',
                url: '/Entrance/doLogin',
                data: $('#form').serialize(),
                success: function (data) {
                    if (data == 1) {
                        layer.msg('登录成功!', {
                            icon: 1,
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        }, function () {
                            window.location.href = "/";
                        });
                    } else if (data == 2) {
                        layer.msg('验证码错误！');
                    }else {
                        layer.msg('登录错误');
                    }
                }
            });
        }
    });

    $(".captcha_img").click(function(){
        new_captcha();
    });

    function new_captcha()
    {
        $.ajax({
            type:'post',
            url:'/Entrance/cap',
            data:{'id':parseInt(100*Math.random())},
            dataType:'json',
            success:function(img){
                $(".captcha_img").attr('src',img);
            }
        });
    }
</script>
</body>
</html>